<?php error_reporting(E_ALL); ?>
<?php 

	class Eventlog {
		
		public static function writeEventlog($row) {
			$date = date("d.m.Y:");
			$time = date("H:i:s");
			$string = "[$date$time] - $row\n";
			$file = fopen('Eventlog.txt', 'a');
			$array = preg_split('/[\n,]+/', file_get_contents('Eventlog.txt'));
			if(sizeof($array)>500) {
				fclose($file);
				$datetime = "[$date$time] - Eventlog.txt";
				rename('Eventlog.txt',$datetime);
				$file = fopen('Eventlog.txt', 'a');
				for ($i = 400; $i < sizeof($array); $i++) {
					fputs($file, $array[$i]);
				}
			}
			
			fwrite($file, $string);
			fclose($file);
		}
		
		public static function deleteEventlog() {
			unlink("Eventlog.txt");
		}
		
	}
?>